angular.module('starter')
  .config(function($stateProvider) {
    $stateProvider.state('workPlatform', {
      url: '/workPlatform',
      templateUrl: 'templates/workPlatform/workPlatform.html',
      controller: 'workPlatformCtrl',
      controllerAs: 'workPlatformCtrl',
      onEnter: function($rootScope) {
        $rootScope.$broadcast('onEnterWorkPlatform');
      },
    })
  })
  .controller('workPlatformCtrl', function($scope,$rootScope,$http) {

    this.getStatisticInfo = function() {
      $http.post("qss/statistic/statisticNum").success(function(res) {
        if (res.success) {
          this.statisticInfo = res.rows;
        }
      });
    };

    this.getStatisticInfo();

    $rootScope.$on("onEnterWorkPlatform", function() {
      this.getStatisticInfo();
    });
  });